from state import State, levels
from userInterface import UserInterface
from command import Command


ui = UserInterface()
playing = True
while playing:
  level = ui.askLevel(levels)
  if level == -1:
    playing = False
    break
  state = State.stateOfLevel(level)
  history = [state]
  ui.show(state)

  ms = {"U": "上", "D": "下", "R": "右", "L": "左"}

  for i in range(10):
      # print(f"第{i}号棋子，{'可以' if state.isPieceCanBePick(i) else '不能'}移动")
      if state.isPieceCanBePick(i):
        for first in ms.keys():
            cmd = Command.moveCommand(str(i), first)
            print(f"命令: {cmd}")
            move = state.buildMove(cmd)
            if move.isValid():
              print(move)
              for second in ms.keys():
                cmd = Command.moveCommand(str(i), first + second)
                print(f"命令: {cmd}")
                move = state.buildMove(cmd)
                if move.isValid():
                  print(move)




